﻿using System.Collections.Generic;

namespace EasyCommonCore.Common
{
    /// <summary>
    /// 深浅拷贝
    /// </summary>
    public static class CloneableCommon
    {
        #region 基于List的深拷贝
       
        /// <summary>
        /// 基于List的深拷贝
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="t"></param>
        /// <returns></returns>
        public static List<T> DeepClone<T>(this List<T> t)
        {
            List<T> temp = new List<T>();
            if (t != null)
            {
                temp.AddRange(t);
            }
            return temp;
        }

        /// <summary>
        /// 浅拷贝
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static List<T> ShallowClone<T>(this List<T> t)
        {
            return t;
        }
        #endregion


    }
}
